#include <iostream>
#include <algorithm>
#include <string>

void min_eq(std::string & s, int a, int len)
{
	if (len & 1) return;
	int l = len/2;
	min_eq(s, a, l);
	min_eq(s, a + l, l);
	int opt = false;
	for (int i = 0; i < l; i++)
		if (s[a + i] > s[a + l + i]) { opt = true; break; }
		else
		if (s[a + i] < s[a + l + i]) break;

	if (opt)
		for (int i = 0; i < l; i++)
			std::swap(s[a + i], s[a + l + i]);
}

int main()
{
	std::ios::sync_with_stdio(false);
	std::string s1, s2;
	std::cin >> s1 >> s2;
	if (s1.size() == s2.size()) {
		min_eq(s1, 0, s1.size());
		min_eq(s2, 0, s2.size());
	}

	std::cout << (s1 == s2 ? "YES" : "NO") << '\n';
}

